import React from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { Button } from 'antd';

import { filterHeader } from '@/assets/common';

import './index.less';

const Header = () => {

  const history = useHistory();
  const { pathname } = useLocation();

  const handleToPath = (path: string) => {
    history.push(path);
  }

  return (
    <>
      {
        !filterHeader(pathname) && (
          <header className="header">
            <div className="header-left">
              <span className="header-title" onClick={() => handleToPath('/')}>我的简历</span>
            </div>

            <div className="header-right">
                {/* 未登录时的状态 */}
                <div className="no-login">
                  <Button className="btn-login" onClick={() => handleToPath('/login')}>登录</Button>
                  <Button className="registered" onClick={() => handleToPath('/register')}>注册</Button>
                </div>
            </div>
          </header>
        )
      }
    </>
  )
}

export default Header;